package pl.perseus.dao;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import pl.perseus.model.Classes;
import pl.perseus.model.Degree;
import pl.perseus.model.Student;

@Repository
public class DegreeDao extends BaseDao<Degree> implements IDegreeDao{
 
	
	public DegreeDao() {
		super("Degree");
	}

	@Override
    public Degree selectByIdDegree(Long id) {
    	Map<String, Object> map = new HashMap<String, Object>();
    	map.put("id", id);
        return queryForObject("getByIdDegree", map);
    }
	
	@Override
	public Degree insertDegree(Degree Degree){
		return insertBean("insertDegree", Degree);
	}
	
	@Override
	public Degree updateDegree(Degree degree){
		return updateBean("updateDegree", degree);
	}
	
	@Override
	public Double getAVGForStudentInClasses(Student s, Classes c){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("studentId", s.getId());
		map.put("classesId", c.getId());
		return (Double) queryForPureObject("getAVGForStudentInClasses", map);
	}
	
	@Override
	public List<Degree> getDegresForStudentAndClasses(Student s, Classes c){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("studentId", s.getId());
		map.put("classesId", c.getId());
		return queryForList("getDegreeByStudentAndClass", map);
	}
 
}
